#include "substitution.h"

#include "expression.h"

Substitution::Substitution(const string & substituted, Expression * substitution)
{
    this->substituted = substituted;
    if(substitution != NULL) this->substitution = substitution->clone();
    else this->substitution = NULL;
}

Substitution::~Substitution()
{
    substituted = "";
    delete substitution; substitution = NULL;
}

Substitution::Substitution(const Substitution & other)
{
    this->substituted = other.substituted;
    if(other.substitution != NULL) this->substitution = other.substitution->clone();
    else this->substitution = NULL;
}

Substitution * Substitution::clone()
{
    return new Substitution(*this);
}

void Substitution::setSubstituted(const string & substituted)
{
    this->substituted = substituted;
}

string Substitution::getSubstituted()
{
    return substituted;
}

void Substitution::setSubstitution(Expression * substitution)
{
    if(substitution != NULL) this->substitution = substitution->clone();
    else this->substitution = NULL;
}

Expression * Substitution::getSubstitution()
{
    return substitution;
}

string Substitution::toString()
{
    return substituted + " -> " + substitution->toString();
}

